import { RouteRecordRaw } from "vue-router";

/**
 * 路由meta对象参数说明
 * meta: {
 *      title:          菜单栏及 tagsView 栏、菜单搜索名称（国际化）
 *      isLink：        是否超链接菜单，开启外链条件，`1、isLink: 链接地址不为空`
 *      isHide：        是否隐藏此路由
 *      isKeepAlive：   是否缓存组件状态
 *      isAffix：       是否固定在 tagsView 栏上
 *      isIframe：      是否内嵌窗口，开启条件，`1、isIframe:true 2、isLink：链接地址不为空`
 *      roles：         当前路由权限标识，取角色管理。控制路由显示、隐藏。超级管理员：admin 普通角色：common
 *      icon：          菜单、tagsView 图标，阿里：加 `iconfont xxx`，fontawesome：加 `fa xxx`
 * }
 */

/**
 * 定义动态路由
 * 前端添加路由，请在顶级节点的 `children 数组` 里添加
 * @description 未开启 isRequestRoutes 为 true 时使用（前端控制路由），开启时第一个顶级 children 的路由将被替换成接口请求回来的路由数据
 * @description 各字段请查看 `/@/views/system/menu/component/addMenu.vue 下的 ruleForm`
 * @returns 返回路由菜单数据
 */
export const dynamicRoutes: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "/",
    component: () => import("/@/layout/index.vue"),
    redirect: "/home",
    meta: {
      isKeepAlive: true
    },
    children: [
      {
        path: "/home",
        name: "home",
        component: () => import("/@/views/home/index.vue"),
        meta: {
          title: "message.router.home",
          isLink: "",
          isHide: false,
          isKeepAlive: true,
          isAffix: true,
          isIframe: false,
          roles: ["admin", "common"],
          icon: "ele-House"
        }
      },
      {
        path: "/user",
        name: "user",
        component: () => import("/@/layout/routerView/parent.vue"),
        redirect: "/user/user",
        meta: {
          title: "成员管理",
          isLink: "",
          isHide: false,
          isKeepAlive: true,
          isAffix: false,
          isIframe: false,
          roles: ["admin", "common"],
          icon: "ele-User"
        },
        children: [
          {
            path: "/user/user",
            name: "user/user",
            component: () => import("/@/views/user/index.vue"),
            meta: {
              title: "成员管理",
              isLink: "",
              isHide: false,
              isKeepAlive: true,
              isAffix: false,
              isIframe: false,
              roles: ["admin", "common"],
              icon: "ele-UserFilled"
            }
          },

          {
            path: "/checkuser",
            name: "checkuser",
            component: () => import("/@/views/user/checkUser.vue"),
            meta: {
              title: "成员审核",
              isLink: "",
              isHide: false,
              isKeepAlive: true,
              isAffix: false,
              isIframe: false,
              roles: ["admin", "common"],
              icon: "ele-Select"
            }
          },
           /* {
            path: "/role",
            name: "role",
            component: () => import("/@/views/user/role.vue"),
            meta: {
              title: "权限管理",
              isLink: "",
              isHide: false,
              isKeepAlive: true,
              isAffix: false,
              isIframe: false,
              roles: ["admin", "common"],
              icon: "iconfont icon-gerenzhongxin"
            }
          }*/
        ]
      },

      {
        path: "/task",
        name: "task",
        component: () => import("/@/layout/routerView/parent.vue"),
        redirect: "/task/task",
        meta: {
          title: "任务管理",
          isLink: "",
          isHide: false,
          isKeepAlive: true,
          isAffix: false,
          isIframe: false,
          roles: ["admin", "common"],
          icon: "ele-List"
        },
        children: [
          {
            path: "/task/task",
            name: "TASK/task",
            component: () => import("/@/views/task/index.vue"),
            meta: {
              title: "任务管理",
              isLink: "",
              isHide: false,
              isKeepAlive: true,
              isAffix: false,
              isIframe: false,
              roles: ["admin", "common"],
              icon: "ele-Checked"
            }
          },
          {
            path: "/task/tasktype",
            name: "tasktype",
            component: () => import("/@/views/tasktype/index.vue"),
            meta: {
              title: "任务类型",
              isLink: "",
              isHide: false,
              isKeepAlive: true,
              isAffix: false,
              isIframe: false,
              roles: ["admin", "common"],
              icon: "ele-Menu"
            }
          }
        ]

      },
      /* {
         path: "/tags",
         name: "tags",
         component: () => import("/@/views/user/index.vue"),
         meta: {
           title: "标签管理",
           isLink: "",
           isHide: false,
           isKeepAlive: true,
           isAffix: false,
           isIframe: false,
           roles: ["admin", "common"],
           icon: "iconfont icon-gerenzhongxin"
         }
       },*/
      {
        path: "/personal",
        name: "personal",
        component: () => import("/@/views/profile/Profile.vue"),
        meta: {
          title: "message.router.personal",
          isLink: "",
          isHide: false,
          isKeepAlive: true,
          isAffix: false,
          isIframe: false,
          roles: ["admin", "common"],
          icon: "ele-Avatar"
        }
      },
      {
        path: "/edithome",
        name: "edithome",
        component: () => import("/@/views/edithome/index.vue"),
        meta: {
          title: "message.router.edithomeinfo",
          isLink: "",
          isHide: false,
          isKeepAlive: true,
          isAffix: false,
          isIframe: false,
          roles: ["admin", "common"],
          icon: "ele-Edit"
        }
      },
      {
        path: "/editarticle",
        name: "editarticle",
        component: () => import("/@/views/article/editarticle.vue"),
        meta: {
          title: "message.router.editarticle",
          isLink: "",
          isHide: true,
          isKeepAlive: true,
          isAffix: false,
          isIframe: false,
          roles: ["admin", "common"],
          icon: "ele-EditPen"
        }
      },
      {
        path: "/addarticle",
        name: "addarticle",
        component: () => import("/@/views/article/addarticle.vue"),
        meta: {
          title: "添加文章",
          isLink: "",
          isHide: true,
          isKeepAlive: true,
          isAffix: false,
          isIframe: false,
          roles: ["admin", "common"],
          icon: "ele-Plus"
        }
      },
      {
        path: "/achievement",
        name: "achievementmenu",
        component: () => import("/@/layout/routerView/parent.vue"),
        redirect: "/achievement/achievement",
        meta: {
          title: "成果管理",
          isLink: "",
          isHide: false,
          isKeepAlive: true,
          isAffix: false,
          isIframe: false,
          roles: ["admin", "common"],
          icon: "ele-Trophy"
        },
        children: [
          {
            path: "/achievement/achievement",
            name: "achievement",
            component: () => import("/@/views/achievement/index.vue"),
            meta: {
              title: "成果管理",
              isLink: "",
              isHide: false,
              isKeepAlive: true,
              isAffix: false,
              isIframe: false,
              roles: ["admin", "common"],
              icon: "ele-Medal"
            }
          },
          {
            path: "/achievement/achievementtype",
            name: "achievementtype",
            component: () => import("/src/views/achievementType/index.vue"),
            meta: {
              title: "成果类型",
              isLink: "",
              isHide: false,
              isKeepAlive: true,
              isAffix: false,
              isIframe: false,
              roles: ["admin", "common"],
              icon: "ele-Collection"
            }
          }
        ]
      },
      {
        path: "/article",
        name: "article",
        component: () => import("/@/layout/routerView/parent.vue"),
        redirect: "/article/article",
        meta: {
          title: "文章管理",
          isLink: "",
          isHide: false,
          isKeepAlive: true,
          isAffix: false,
          isIframe: false,
          roles: ["admin", "common"],
          icon: "ele-Document"
        },
        children: [
          {
            path: "/article/article",
            name: "article/article",
            component: () => import("/@/views/article/index.vue"),
            meta: {
              title: "文章管理",
              isLink: "",
              isHide: false,
              isKeepAlive: true,
              isAffix: false,
              isIframe: false,
              roles: ["admin", "common"],
              icon: "ele-Reading"
            }
          },
          {
            path: "/article/articletype",
            name: "articletype",
            component: () => import("/@/views/articleType/index.vue"),
            meta: {
              title: "文章类型",
              isLink: "",
              isHide: false,
              isKeepAlive: true,
              isAffix: false,
              isIframe: false,
              roles: ["admin", "common"],
              icon: "ele-Files"
            }
          }
        ]
      }, {
        path: "/resource",
        name: "resource",
        component: () => import("/@/layout/routerView/parent.vue"),
        redirect: "/resource/resource",
        meta: {
          title: "资源管理",
          isLink: "",
          isHide: false,
          isKeepAlive: true,
          isAffix: false,
          isIframe: false,
          roles: ["admin", "common"],
          icon: "ele-FolderOpened"
        },
        children: [
          {
            path: "/resource/resource",
            name: "resource/resource",
            component: () => import("/@/views/resource/index.vue"),
            meta: {
              title: "资源管理",
              isLink: "",
              isHide: false,
              isKeepAlive: true,
              isAffix: false,
              isIframe: false,
              roles: ["admin", "common"],
              icon: "ele-Folder"
            }
          },
          {
            path: "/resource/resourcetype",
            name: "resourcetype",
            component: () => import("/@/views/resourceType/index.vue"),
            meta: {
              title: "资源类型",
              isLink: "",
              isHide: false,
              isKeepAlive: true,
              isAffix: false,
              isIframe: false,
              roles: ["admin", "common"],
              icon: "ele-Grid"
            }
          }
        ]
      },
      {
        path: "/album",
        name: "album",
        component: () => import("/@/layout/routerView/parent.vue"),
        redirect: "/album/album",
        meta: {
          title: "相册管理",
          isLink: "",
          isHide: false,
          isKeepAlive: true,
          isAffix: false,
          isIframe: false,
          roles: ["admin", "common"],
          icon: "ele-Picture"
        },
        children: [
          {
            path: "/album/album",
            name: "album/album",
            component: () => import("/@/views/album/index.vue"),
            meta: {
              title: "相册管理",
              isLink: "",
              isHide: false,
              isKeepAlive: true,
              isAffix: false,
              isIframe: false,
              roles: ["admin", "common"],
              icon: "ele-PictureFilled"
            }
          },
          {
            path: "/album/albumtype",
            name: "albumtype",
            component: () => import("/@/views/albumType/index.vue"),
            meta: {
              title: "相册类型",
              isLink: "",
              isHide: false,
              isKeepAlive: true,
              isAffix: false,
              isIframe: false,
              roles: ["admin", "common"],
              icon: "ele-Camera"
            }
          }
        ]
      },
      {
        path: "/editalbum",
        name: "editalbum",
        component: () => import("/@/views/album/editalbum.vue"),
        meta: {
          title: "message.router.editalbum",
          isLink: "",
          isHide: true,
          isKeepAlive: true,
          isAffix: false,
          isIframe: false,
          roles: ["admin", "common"],
          icon: "ele-PictureRounded"
        }
      },
      // {
      //   path: "/iframeweb",
      //   name: "iframeweb",
      //   component: () => import("/@/layout/routerView/iframes.vue"),
      //   meta: {
      //     title: "message.router.iframeweb",
      //     isLink: "http://localhost:9797/",
      //     isHide: false,
      //     isKeepAlive: false,
      //     isAffix: false,
      //     isIframe: true,
      //     roles: ["admin"],
      //     icon: "iconfont icon-neiqianshujuchucun"
      //   }
      // }
    ]
  }
];

/**
 * 定义404、401界面
 * @link 参考：https://next.router.vuejs.org/zh/guide/essentials/history-mode.html#netlify
 */
export const notFoundAndNoPower = [
  {
    path: "/:path(.*)*",
    name: "notFound",
    component: () => import("/@/views/error/404.vue"),
    meta: {
      title: "message.staticRoutes.notFound",
      isHide: true
    }
  },
  {
    path: "/401",
    name: "noPower",
    component: () => import("/@/views/error/401.vue"),
    meta: {
      title: "message.staticRoutes.noPower",
      isHide: true
    }
  }
];

/**
 * 定义静态路由（默认路由）
 * 此路由不要动，前端添加路由的话，请在 `dynamicRoutes 数组` 中添加
 * @description 前端控制直接改 dynamicRoutes 中的路由，后端控制不需要修改，请求接口路由数据时，会覆盖 dynamicRoutes 第一个顶级 children 的内容（全屏，不包含 layout 中的路由出口）
 * @returns 返回路由菜单数据
 */
export const staticRoutes: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "/",
    component: () => import("/@/layout/index.vue"),
    meta: {
      title: "布局界面"
    },
    children: [
      // 请不要往这里 `children` 中添加内容，此内容为了防止 No match found for location with path "xxx" 问题
      ...notFoundAndNoPower
    ]
  },
  {
    path: "/login",
    name: "login",
    component: () => import("/@/views/login/index.vue"),
    meta: {
      title: "登录"
    }
  }
];
